package com.quantgroup.data.util;

import cn.hutool.core.util.StrUtil;
import org.slf4j.MDC;

/*
 * 系统访问者工具类
 * */
public class VisitorUtil {

    public static final String ANONYMOUS = "anonymous";
    public static final String VISITOR = "Z-VISITOR";

    public static void setVisitor(String visitor) {
        if (StrUtil.isEmpty(visitor)) {
            visitor = ANONYMOUS;
        }
        MDC.put(VISITOR, visitor);
    }

    public static String getVisitor() {
        String s = MDC.get(VISITOR);
        return s == null ? ANONYMOUS : s;
    }
}
